package com.prj.ufdm.cloud.hystrix;

import org.springframework.context.annotation.Configuration;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;

@Configuration
public class MyService {
	
	@HystrixCommand(fallbackMethod = "fallback")
	public String ok() {
		int i = 1/0;
		return "OK";
	}

	@HystrixCommand(fallbackMethod = "fallback")
	public String fail(boolean throwSomething) {
		
		System.out.println("\n throwSomething: "+throwSomething);
		
		if(throwSomething)
		  throw new RuntimeException("fail now");
		else
		  return "";

	}

	public String fallback() {
		return "from the fallback";
	}

	public String fallback(boolean throwSomething) {
		return "from the fallback";
	}
}
